package com.xoa.controller.party;


import com.xoa.model.party.GridInfo;
import com.xoa.model.users.Users;
import com.xoa.service.party.GridInfoService;
import com.xoa.util.AjaxJson;
import com.xoa.util.ToJson;
import com.xoa.util.common.session.SessionUtils;
import com.xoa.util.common.wrapper.BaseWrapper;
import com.xoa.util.common.wrapper.BaseWrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by gsb on 2017/9/7.
 */
@RestController
@RequestMapping("/gridInfo")
public class GridInfoController {

    @Autowired
    private GridInfoService gridInfoService;

    //获取下级的网格
    @RequestMapping("/gridSettingsTree")
    public ToJson<GridInfo> gridSettingsTree(HttpServletRequest request, String  typeId){

        return gridInfoService.gridSettingsTree(request,typeId);
    }
    //获取下级的网格
    @RequestMapping("/gridSettingsTrees")
    public ToJson<GridInfo> gridSettingsTrees(HttpServletRequest request, String  typeId){

        return gridInfoService.gridSettingsTrees(request,typeId);
    }

    //获取全部网格
    @RequestMapping("/gridSettingsList")
    public BaseWrappers gridSettingsList(HttpServletRequest request, Integer griti){
        return gridInfoService.gridSettingsList(request,griti);
    }


    //获取全部下级网格
    @RequestMapping("/gridSettingsTreeList")
    public ToJson<GridInfo> gridSettingsTreeList(HttpServletRequest request){
        return gridInfoService.gridSettingsTreeList(request);
    }
//添加网格
    @RequestMapping("/insertSelective")
    public BaseWrappers insertSelective(GridInfo gridInfo){

        return gridInfoService.insertSelective(gridInfo);
    }
//编辑网格
    @RequestMapping("/updateByPrimaryKeySelective")
    public BaseWrappers updateByPrimaryKeySelective(GridInfo gridInfo){

        return gridInfoService.updateByPrimaryKeySelective(gridInfo);
    }
//删除网格
    @RequestMapping("/deleteByPrimaryKey")
    public BaseWrappers deleteByPrimaryKey(Integer gridInfo){

        return gridInfoService.deleteByPrimaryKey(gridInfo);
    }
//单查网格
    @RequestMapping("/selectByPrimaryKey")
    public BaseWrapper selectByPrimaryKey(Integer gridInfo, HttpServletRequest request){

        return gridInfoService.selectByPrimaryKey(gridInfo,request);
    }
//查询网格下面的网格员 根据主键ID
    @RequestMapping("/getUserName")
        public BaseWrappers getUserName(String gridInfo){

        return gridInfoService.getUserName(gridInfo);
    }
 //添加网格员
    @RequestMapping("/updateOrByPrimaryKey")
    public BaseWrapper updateOrByPrimaryKey(Integer gridId, String usId){

        return gridInfoService.updateOrDeleteByPrimaryKey(gridId,gridInfoService.PRCS_FLAG_WILL,usId);
    }
// 删除网格员
    @RequestMapping("/deleteOrByPrimaryKey")
    public BaseWrapper deleteOrByPrimaryKey(Integer gridId, String usId){
        return gridInfoService.updateOrDeleteByPrimaryKey(gridId,gridInfoService.PRCS_FLAG_OVER,usId);
    }

    @RequestMapping("/selectByUid")
    public BaseWrappers selectByUid(HttpServletRequest request){
        return gridInfoService.selectByUid(request);
    }

    @RequestMapping("/queryByUidMessage")
    public BaseWrapper queryByUidMessage(Integer uid){
        return gridInfoService.queryByUidMessage(uid);
    }

 /*   @RequestMapping("/insertImportGridInfo")
    public BaseWrapper insertImportGridInfo(HttpServletRequest request, HttpServletResponse response, HttpSession session, MultipartFile file) throws IOException {
        return  gridInfoService.insertImportGridInfo(request,response,session,file);
    }*/

    //单查网格
    @RequestMapping("/selectGrid")
    public AjaxJson selectGrid(HttpServletRequest request){
        Users user= SessionUtils.getSessionInfo(request.getSession(), Users.class, new Users());
        return gridInfoService.selectGrid(user);
    }


}
